# coding : UTF-8
"""
作者：BingBO   时间：2022年10月13日
自动调整代码格式 ：Alt+Ctrl+L
"""
import numpy as np
from numpy.linalg import lstsq  # 解超定方程
from numpy.linalg import solve  # 解线性方程

# from scipy.linalg import solve

# 直线方程 y = kx+b 转换到 kx-y+b=0
k, b = 0.43, 303
A, B, C = k, -1, b

# 直线方程 Ax+By+C = 0
A1, B1, C1 = 1, 0, 5
A2, B2, C2 = 2, -1, 197

y = (C2 * A1 - C1 * A2) / (B1 * A2 - B2 * A1)
print(y)
x = (-B1 * y - C1) / A1
print(x)
x = (-B2 * y - C2) / A2
print(x)
'''
A = np.mat([[1, 0, 5], [2, -1, 197]])
b = np.transpose(np.mat([[0, 0, 0])
x = np.linalg.solve(A, b)
print(x)
'''
# AX = b
A = np.array([[1, 0], [2, -1]])  # 输出系数矩阵A
b = np.array([-5, -197])  # 值
x = solve(A, b)
print(x)
